<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="description" content="{{env('SITE_DESCRIPTION')}}">
    <title>{{env('SITE_TITLE')}}</title>

    <link href="{{asset('/org/site')}}/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css"/>
    <link href="{{asset('/org/site')}}/AmazeUI-2.4.2/assets/css/admin.css" rel="stylesheet" type="text/css"/>

    <link href="{{asset('/org/site')}}/basic/css/demo.css" rel="stylesheet" type="text/css"/>

    <link href="{{asset('/org/site')}}/css/seastyle.css" rel="stylesheet" type="text/css"/>

    {{--<script type="text/javascript" src="{{asset('/org/site')}}/basic/js/jquery-1.7.min.js"></script>--}}
    {{--    <script type="text/javascript" src="{{asset('/org/site')}}/js/script.js"></script>--}}
    @include('admin.layouts._hdjs')
</head>

<body>
{{--公共的顶部导航和搜索框--}}
@include('site.layouts._top')

<div class="clear"></div>
<b class="line"></b>
<div class="search">
    <div class="search-list">
        <div class="nav-table">
            <div class="long-title" style="cursor: pointer">
                <span class="all-goods">
                    商城首页
                </span>
            </div>
            <div class="nav-cont">
                <ul style="display: none">
                    <li class="index"><a href="{{route('site.index')}}">首页</a></li>
                    <li class="qc hidden"><a href="#">闪购</a></li>
                    <li class="qc"><a href="#">限时抢</a></li>
                    <li class="qc"><a href="#">团购</a></li>
                    <li class="qc last"><a href="#">大包装</a></li>
                </ul>
                @auth('web')
                    <div class="nav-extra">
                        <i class="am-icon-user-secret am-icon-md nav-user"></i><b></b>我的空间
                        <i class="am-icon-angle-right" style="padding-left: 10px;"></i>
                    </div>
                @endauth
            </div>
        </div>
        <script>
            //通过下面的方式在js中抓取元素,自动给抓取到到的元素添加事件,这样就不需要在元素上写onclick之类的事件了.
            $(function () {
                //用户js的方式给商城首页加上超链接跳转
                $(".long-title").click(function () {
                    location.href = "{{route('site.index')}}";
                });
                $(".nav-extra").click(function () {
                    //用js跳转到用户个人空间页面
                    location.href = "{{route('site.center.where','index')}}";
                });
            })
        </script>

        <div class="am-g am-g-fixed">
            <div class="am-u-sm-12 am-u-md-12">
                <div class="search-content">
                    <div class="sort">
                        <li class="first"><a title="综合">综合排序</a></li>
                    </div>
                    <div class="clear"></div>

                    <ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-4 boxes">
                        {{--展示当前分类下的所有商品--}}
                        @foreach($goods as $good)
                            <li>
                                <a href="{{route('site.detail',$good['id'])}}">
                                    <div class="i-pic limit">
                                        <img src="{{$good['pics'][0]}}" width="220px" height="220px"/>
                                        <p class="title fl">{{$good['title']}}</p>
                                        <p class="price fl">
                                            <b>¥</b>
                                            <strong>{{$good['price']}}</strong>
                                        </p>
                                        <p class="number fl">
                                            销量<span>{{random_int(1,100)}}</span>
                                        </p>
                                    </div>
                                </a>
                            </li>
                        @endforeach
                        {{--在前台获取当前请求要展示的栏目的id--}}
                        {{--dd(request('category')['id'])--}}
                        {{--下面这部分是数据是我人为强行给列表页面加上的,目的就是让页面上的东西多点儿--}}
                        @foreach(\App\Models\Goods::latest()->select('id','title','price','pics')->get()->random(0) as $fill)
                            {{--但是展示的内容不能和当前请求的栏目在同一个栏目,所以要排除掉商品栏目在当前栏目下的那些商品--}}
                            {{--但是这里是展示用户输入的搜索结果,页面所以不需要判断是否在同一个栏目中--}}
                            <li>
                                <a href="{{route('site.detail',$fill)}}">
                                    <div class="i-pic limit">
                                        <img src="{{$fill['pics'][0]}}" width="220px" height="220px"/>
                                        <p class="title fl">{{$fill['title']}}</p>
                                        <p class="price fl">
                                            <b>¥</b>
                                            <strong>{{$fill['price']}}</strong>
                                        </p>
                                        <p class="number fl">
                                            销量<span>1110</span>
                                        </p>
                                    </div>
                                </a>
                            </li>
                        @endforeach

                    </ul>
                </div>
                <div class="search-side">

                    <div class="side-title">
                        经典搭配
                    </div>
                    @foreach(\App\Models\Goods::oldest()->select('id','pics','title','price','category_id')->get()->random(3) as $fill)
                        {{--但是展示的内容不能和当前请求的栏目在同一个栏目,所以要排除掉商品栏目在当前栏目下的那些商品--}}
                        @if(!in_array(request('category')['id'],$fill['category_id']))
                            <li>
                                <a href="{{route('site.detail',$fill)}}">
                                    <div class="i-pic check">
                                        <img src="{{$fill['pics'][0]}}" width="220px" height="220px"/>
                                        <p class="check-title" style="font-size: 18px">
                                            {{mb_substr($fill['title'],0,8)}}
                                        </p>
                                        <p class="price fl">
                                            <b>¥</b>
                                            <strong>{{$fill['price']}}</strong>
                                        </p>
                                        <p class="number fl">
                                            销量<span>{{random_int(1,100)}}</span>
                                        </p>
                                    </div>
                                </a>
                            </li>
                        @endif
                    @endforeach

                </div>
                <div class="clear"></div>
                <!--分页,暂时商品比较少用不到 -->
                <ul class="am-pagination am-pagination-right " style="display: none;">
                    <li class="am-disabled"><a href="#">&laquo;</a></li>
                    <li class="am-active"><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li><a href="#">&raquo;</a></li>
                </ul>

            </div>
        </div>
        {{--公共的底部--}}
        @include('site.layouts._bottom')
    </div>

</div>

<!--引导 -->
<div class="navCir">
    <li><a href="home.html"><i class="am-icon-home "></i>首页</a></li>
    <li><a href="sort.html"><i class="am-icon-list"></i>分类</a></li>
    <li><a href="shopcart.html"><i class="am-icon-shopping-basket"></i>购物车</a></li>
    <li><a href="{{asset('/org/site')}}/person/index.html"><i class="am-icon-user"></i>我的</a></li>
</div>

<!--公共的侧边栏菜单 -->
@include('site.layouts._slidebar')

<script type="text/javascript" src="{{asset('/org/site')}}/basic/js/quick_links.js"></script>

<div class="theme-popover-mask"></div>
{{--@if(isset($info))--}}
@if(request()->cookie('name'))
    <script>
        //session() 全局辅助函数可以用来获取或者设置 Session 值
        //要确定 Session 中是否存在某个值，可以使用 has 方法。如果该值存在且不为 null，那么 has 方法会返回 true
        $(function () {
            require(['hdjs'], function (hdjs) {
                hdjs.swal({
                    text: "哥们儿,你搜的东西找不到,随机给你几个,你凑合着先看看!",
                    button: false,
                    icon: "info"
                })
            })
        })
    </script>
@endif


</body>

</html>
